﻿using UnityEngine;
using System.Collections;

public class CharacterItemStoreUnit : MonoBehaviour {
	public UILabel charLvLabel;
	public UILabel charNameLabel;
	public UILabel charCostLabel;
	public GameObject char3DModel;

	public GameObject[] charTraitList;
	public GameObject[] charRare;

	public DStoreCharacter charInfo;

    public GameObject backButtonObject;

    public GameObject moreInfoButton;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	public bool isCardBack = false;
	public void OnClickCardBackButton()
	{
        SoundController.PlaySound("UI_card_single");
		if( !isCardBack )
		{
			GetComponent<Animation>().Play("Turn_Front-Back");
            FlipBackButtonImage(true);
		}
		else
		{
			GetComponent<Animation>().Play("Turn_Back-Front");
            FlipBackButtonImage(false);
		}
	}

    public void FlipBackButtonImage(bool isCardBack)
    {
        this.isCardBack = isCardBack;
        if (backButtonObject.transform.localRotation.y == 0f && isCardBack)
        {
            backButtonObject.transform.localRotation = Quaternion.Euler(new Vector3(0f, 180f, 0f));
        }
        else if (backButtonObject.transform.localRotation.y != 0f && !isCardBack)
        {
            backButtonObject.transform.localRotation = Quaternion.Euler(new Vector3(0f, 0f, 0f));
        }
    }
}
